package com.dhj.streamTest2;

import com.dhj.streamTest.entity.Author;

import java.util.List;

import static com.dhj.streamTest.entity.AuthorList.getAuthors;

public class Demo2 {

    public static void main(String[] args) {
        List<Author> authors = getAuthors();

        long count = authors.stream().count();
        System.out.println(count);

        System.out.println("-------------------------------");

        long count1 = authors.stream().distinct()
                .flatMap(author -> author.getBooks().stream()).count();

        System.out.println(count1);


        System.out.println("----------------------------------");


        authors.stream().distinct().forEach(author -> {
            long count2 = author.getBooks().stream().count();
            System.out.println(author.getName()+" book num is "+count2);

        });





    }
}
